import { App, VNode, render, createVNode } from 'vue'
import Loading from './index.vue'

export default {
  install(app:App) {
    const Vnode:VNode = createVNode(Loading)        // 创建虚拟节点
    render(Vnode, document.body)
    // console.log('install', app, "=========", Vnode?.component?.setupState)     // 会有报错
    console.log('install', app, "=========", Vnode?.component?.exposed)           // 在Loading页面通过defineExpose抛出所有的属性和方法，然后在此处接收

    app.config.globalProperties.$loading = {
      show: Vnode.component?.exposed?.show,
      hide: Vnode.component?.exposed?.hide,
    }
  }
}